// index.js
const app = getApp();

Page({
  data: {
    touchStartX: 0,
    touchStartY: 0,
    touchMoveX: 0,
    touchMoveY: 0,
    touchStartXX: 0,
    touchStartYY: 0,

    stageOneShow: true,
    stageTwoShow: false,

    numberList: [{
      id:1,
      nowNum: ''
    },{
      id:2,
      nowNum: ''
    },{
      id:3,
      nowNum: ''
    },{
      id:4,
      nowNum: ''
    }],

    startAni: {},
    stageTwoZoomIn: {},
    stageTwoOpac: false,

    canvasShow: false,
    stageThreeShow: false,
    videoTwoOverAni: {},
    stageThreeOverShow: false,
    stageThreePointShow: false,
    stageThreeArrow: false,
    stageThreeText: false,

    stageFourShow: false,
    stageFourOverShow: false,
    stageFourOpac: false,
    stageFourPoint: {},

    stageFiveShow: false,
    stageFiveOverShow: false,
    stageFiveOpac: false,

    stageSixShow: false,
    stageSixOverShow: false,
    stageSixPoint: {},
    stageSixOpac: false,

    stageSevenShow: false,
    stageSevenOverShow: false,
    stageSevenPoint: {},
    stageSevenOpac: false,

    stageEightShow: false,
    stageEightOverShow: false,
    stageEightOpac: false,

    stageLastShow: false,
    stageLastOpac: false,
    
    listShow: false,
    
    popShow: false,
    background: [],
    indicatorDots: false,
    vertical: false,
    autoplay: false,
    interval: 2000,
    duration: 500,
    swiperCurrent: 0,

    bgmComfirm: false,
    musicShow: false,

    id: 0,
    type: '',
    popUrl: '',
    lastList: [
      [{
        id: 0,
        url: 'https://gqb.oss-cn-shanghai.aliyuncs.com/jlb/listimg/01/fm.jpg',
        type: 'img',
        content: ['https://gqb.oss-cn-shanghai.aliyuncs.com/jlb/listimg/01/pic.jpg']
      },{
        id:2,
        url: 'https://gqb.oss-cn-shanghai.aliyuncs.com/jlb/listimg/03/fm.jpg',
        type: 'video',
        content: ['https://gqb.oss-cn-shanghai.aliyuncs.com/jlb/list/0719.mp4']
      },{
        id:4,
        url: 'https://gqb.oss-cn-shanghai.aliyuncs.com/jlb/listimg/06/fm.jpg',
        type: 'video',
        content: ['https://gqb.oss-cn-shanghai.aliyuncs.com/jlb/list/131311.mp4']
      },{
        id:1515,
        url: 'https://gqb.oss-cn-shanghai.aliyuncs.com/jlb/listimg/17/fm.jpg',
        type: 'img',
        content: ['https://gqb.oss-cn-shanghai.aliyuncs.com/jlb/listimg/17/pic.jpg']
      },{
        id:6,
        url: 'https://gqb.oss-cn-shanghai.aliyuncs.com/jlb/listimg/08/fm.jpg',
        type: 'img',
        content: ['https://gqb.oss-cn-shanghai.aliyuncs.com/jlb/listimg/08/Slide2.JPG','https://gqb.oss-cn-shanghai.aliyuncs.com/jlb/listimg/08/Slide3.JPG','https://gqb.oss-cn-shanghai.aliyuncs.com/jlb/listimg/08/Slide4.JPG','https://gqb.oss-cn-shanghai.aliyuncs.com/jlb/listimg/08/Slide5.JPG','https://gqb.oss-cn-shanghai.aliyuncs.com/jlb/listimg/08/Slide6.JPG','https://gqb.oss-cn-shanghai.aliyuncs.com/jlb/listimg/08/Slide7.JPG','https://gqb.oss-cn-shanghai.aliyuncs.com/jlb/listimg/08/Slide8.JPG']
      },{
        id:1313,
        url: 'https://gqb.oss-cn-shanghai.aliyuncs.com/jlb/listimg/15/fm.jpg',
        type: 'video',
        content: ['https://gqb.oss-cn-shanghai.aliyuncs.com/jlb/list/0903.mp4']
      },{
        id:8,
        url: 'https://gqb.oss-cn-shanghai.aliyuncs.com/jlb/listimg/10/fm.jpg',
        type: 'img',
        content: ['https://gqb.oss-cn-shanghai.aliyuncs.com/jlb/listimg/10/pic.jpg']
      },{
        id:10,
        url: 'https://gqb.oss-cn-shanghai.aliyuncs.com/jlb/listimg/12/fm.jpg',
        type: 'img',
        content: ['https://gqb.oss-cn-shanghai.aliyuncs.com/jlb/listimg/12/pic.jpg']
      },{
        id:12,
        url: 'https://gqb.oss-cn-shanghai.aliyuncs.com/jlb/listimg/14/fm.jpg',
        type: 'img',
        content: ['https://gqb.oss-cn-shanghai.aliyuncs.com/jlb/listimg/14/pic.jpg']
      },{
        id:55,
        url: 'https://gqb.oss-cn-shanghai.aliyuncs.com/jlb/listimg/07/fm.jpg',
        type: 'video',
        content: ['https://gqb.oss-cn-shanghai.aliyuncs.com/jlb/list/0803.mp4']
      },{
        id:14,
        url: 'https://gqb.oss-cn-shanghai.aliyuncs.com/jlb/listimg/16/fm.jpg',
        type: 'video',
        content: ['https://gqb.oss-cn-shanghai.aliyuncs.com/jlb/list/wn_youth_zone.mp4']
      },{
        id:111,
        url: 'https://gqb.oss-cn-shanghai.aliyuncs.com/jlb/listimg/02/fm.jpg',
        type: 'video',
        content: ['https://gqb.oss-cn-shanghai.aliyuncs.com/jlb/list/fxsp.mp4']
      },{
        id:16,
        url: 'https://gqb.oss-cn-shanghai.aliyuncs.com/jlb/listimg/18/fm.jpg',
        type: 'img',
        content: ['https://gqb.oss-cn-shanghai.aliyuncs.com/jlb/listimg/18/pic.jpg']
      }],
      [{
        type: 'title'
      },{
        id:1,
        url: 'https://gqb.oss-cn-shanghai.aliyuncs.com/jlb/listimg/02/fm.jpg',
        type: 'video',
        content: ['https://gqb.oss-cn-shanghai.aliyuncs.com/jlb/list/fxsp.mp4']
      },{
        id:3,
        url: 'https://gqb.oss-cn-shanghai.aliyuncs.com/jlb/listimg/05/fm.jpg',
        type: 'img',
        content: ['https://gqb.oss-cn-shanghai.aliyuncs.com/jlb/listimg/05/pic.jpg']
      },{
        id:5,
        url: 'https://gqb.oss-cn-shanghai.aliyuncs.com/jlb/listimg/07/fm.jpg',
        type: 'video',
        content: ['https://gqb.oss-cn-shanghai.aliyuncs.com/jlb/list/0803.mp4']
      },{
        id:1414,
        url: 'https://gqb.oss-cn-shanghai.aliyuncs.com/jlb/listimg/16/fm.jpg',
        type: 'video',
        content: ['https://gqb.oss-cn-shanghai.aliyuncs.com/jlb/list/wn_youth_zone.mp4']
      },{
        id:1616,
        url: 'https://gqb.oss-cn-shanghai.aliyuncs.com/jlb/listimg/18/fm.jpg',
        type: 'img',
        content: ['https://gqb.oss-cn-shanghai.aliyuncs.com/jlb/listimg/18/pic.jpg']
      },{
        id:7,
        url: 'https://gqb.oss-cn-shanghai.aliyuncs.com/jlb/listimg/09/fm.jpg',
        type: 'img',
        content: ['https://gqb.oss-cn-shanghai.aliyuncs.com/jlb/listimg/09/Slide10.JPG','https://gqb.oss-cn-shanghai.aliyuncs.com/jlb/listimg/09/Slide11.JPG','https://gqb.oss-cn-shanghai.aliyuncs.com/jlb/listimg/09/Slide12.JPG','https://gqb.oss-cn-shanghai.aliyuncs.com/jlb/listimg/09/Slide13.JPG','https://gqb.oss-cn-shanghai.aliyuncs.com/jlb/listimg/09/Slide14.JPG','https://gqb.oss-cn-shanghai.aliyuncs.com/jlb/listimg/09/Slide15.JPG','https://gqb.oss-cn-shanghai.aliyuncs.com/jlb/listimg/09/Slide16.JPG']
      },{
        id:9,
        url: 'https://gqb.oss-cn-shanghai.aliyuncs.com/jlb/listimg/11/fm.jpg',
        type: 'img',
        content: ['https://gqb.oss-cn-shanghai.aliyuncs.com/jlb/listimg/11/pic.jpg']
      },{
        id:11,
        url: 'https://gqb.oss-cn-shanghai.aliyuncs.com/jlb/listimg/13/fm.jpg',
        type: 'img',
        content: ['https://gqb.oss-cn-shanghai.aliyuncs.com/jlb/listimg/13/pic.jpg']
      },{
        id:13,
        url: 'https://gqb.oss-cn-shanghai.aliyuncs.com/jlb/listimg/15/fm.jpg',
        type: 'video',
        content: ['https://gqb.oss-cn-shanghai.aliyuncs.com/jlb/list/0903.mp4']
      },{
        id:22,
        url: 'https://gqb.oss-cn-shanghai.aliyuncs.com/jlb/listimg/03/fm.jpg',
        type: 'video',
        content: ['https://gqb.oss-cn-shanghai.aliyuncs.com/jlb/list/0719.mp4']
      },{
        id:15,
        url: 'https://gqb.oss-cn-shanghai.aliyuncs.com/jlb/listimg/17/fm.jpg',
        type: 'img',
        content: ['https://gqb.oss-cn-shanghai.aliyuncs.com/jlb/listimg/17/pic.jpg']
      },{
        id:17,
        url: 'https://gqb.oss-cn-shanghai.aliyuncs.com/jlb/listimg/19/fm.jpg',
        type: 'img',
        content: ['https://gqb.oss-cn-shanghai.aliyuncs.com/jlb/listimg/19/Slide1.JPG','https://gqb.oss-cn-shanghai.aliyuncs.com/jlb/listimg/19/Slide2.JPG','https://gqb.oss-cn-shanghai.aliyuncs.com/jlb/listimg/19/Slide3.JPG','https://gqb.oss-cn-shanghai.aliyuncs.com/jlb/listimg/19/Slide4.JPG','https://gqb.oss-cn-shanghai.aliyuncs.com/jlb/listimg/19/Slide6.JPG','https://gqb.oss-cn-shanghai.aliyuncs.com/jlb/listimg/19/Slide7.JPG','https://gqb.oss-cn-shanghai.aliyuncs.com/jlb/listimg/19/Slide8.JPG','https://gqb.oss-cn-shanghai.aliyuncs.com/jlb/listimg/19/Slide9.JPG','https://gqb.oss-cn-shanghai.aliyuncs.com/jlb/listimg/19/Slide10.JPG','https://gqb.oss-cn-shanghai.aliyuncs.com/jlb/listimg/19/Slide11.JPG','https://gqb.oss-cn-shanghai.aliyuncs.com/jlb/listimg/19/Slide12.JPG','https://gqb.oss-cn-shanghai.aliyuncs.com/jlb/listimg/19/Slide13.JPG','https://gqb.oss-cn-shanghai.aliyuncs.com/jlb/listimg/19/Slide14.JPG',]
      }]
    ]
  },

  // 弹窗关闭
  popClose(e) {
    this.setData({
      popShow: false
    })
  },
  // list 点击事件
  openPopTap(e) {
    let list = this.data.lastList, id = e.currentTarget.id, that = this;
    let type = '', popUrl = '', background = [];
    for (let i=0;i<list.length;i++) {
      for (let j=0;j<list[i].length;j++){
        if (id == list[i][j].id) {
          type = list[i][j].type;
          if (list[i][j].content.length > 2){
            background = list[i][j].content
          }else{
            popUrl = list[i][j].content;
          }
          console.log(id,type,popUrl);
        }
      }
    }
    this.setData({
      id,
      type,
      popUrl,
      background,
      popShow: true
    })
  },
  // swiper dot 事件
  bindchange(e) {
    let list = this.data.background, id = e.detail.current, videoCtx;
    for (let i=0;i<list.length;i++) {
      if (list[i].type == 'video') {
        videoCtx = wx.createVideoContext(list[i].id);
        videoCtx.pause();
      }
      if (id == list[i].id) {
        videoCtx = wx.createVideoContext(id);
        videoCtx.play();
      }
    }
    this.setData({
      swiperCurrent: e.detail.current
    })
  },
  // 最后一个视频播放完毕
  videoLastEnded(e) {
    if (e.detail.currentTime > 12) {
    //if (e.detail.currentTime > 14) {
      this.bgm.pause();
      this.setData({
        listShow: true,
        musicShow: false
      })
    }
  },
  // 第七个视频点击事件
  stageEightTap() {
    let that = this;
    this.stageEightConfirm = true;
    this.setData({
      stageLastShow: true
    })
    setTimeout(() => {
      that.setData({
        stageEightShow: false,
        stageLastOpac: true
      })
    }, 300);
  },
  // 第七个视频播放完毕
  videoSevenEnded() {
    let that = this;
    this.setData({
      stageEightOverShow: true
    })
    setTimeout(() => {
      if(this.stageEightConfirm) return;
      that.setData({
        stageLastShow: true
      })
      setTimeout(() => {
        that.setData({
          stageEightShow: false,
          stageLastOpac: true
        })
      }, 300);
    }, 12000);
    setTimeout(() => {
      that.setData({
        listShow: true
      })
    }, 20000);
  },
  // 第六个视频播放完毕
  videoSixEnded() {
    let that = this;
    let stageSevenPointAni = wx.createAnimation({
      duration: 1000,
      timingFunction: 'linear',
    }).translate(300,0).opacity(0).step();
    let pointNext = true;
    setInterval(() => {
      if (pointNext){
        stageSevenPointAni = wx.createAnimation({
          duration: 0,
        }).translate(0,0).opacity(1).step();
        that.setData({
          stageSevenPoint: stageSevenPointAni.export()
        })
        pointNext = !pointNext;
      }else{
        stageSevenPointAni = wx.createAnimation({
          duration: 1000,
          timingFunction: 'linear',
        }).translate(300,0).opacity(0).step();
        that.setData({
          stageSevenPoint: stageSevenPointAni.export()
        })
        pointNext = !pointNext;
      }
    }, 1000);

    this.setData({
      canvasShow: true,
      stageSevenPoint: stageSevenPointAni.export(),
      stageSevenOverShow: true
    })

    setTimeout(() => {
      if(this.stageSevenConfirm) return;
      that.setData({
        canvasShow: false,
        stageEightShow: true
      })
      setTimeout(() => {
        that.setData({
          stageSevenShow: false,
          stageEightOpac: true
        })
      }, 300);
    }, 12000);
  },
  // 第五个视频播放完毕
  videoFiveEnded() {
    let that = this;
    let stageSixPointAni = wx.createAnimation({
      duration: 1000,
      timingFunction: 'linear',
    }).translate(0,150).opacity(0).step();
    let pointNext = true;
    setInterval(() => {
      if (pointNext){
        stageSixPointAni = wx.createAnimation({
          duration: 0,
        }).translate(0,0).opacity(1).step();
        that.setData({
          stageSixPoint: stageSixPointAni.export()
        })
        pointNext = !pointNext;
      }else{
        stageSixPointAni = wx.createAnimation({
          duration: 1000,
          timingFunction: 'linear',
        }).translate(0,150).opacity(0).step();
        that.setData({
          stageSixPoint: stageSixPointAni.export()
        })
        pointNext = !pointNext;
      }
    }, 1000);

    this.setData({
      canvasShow: true,
      stageSixPoint: stageSixPointAni.export(),
      stageSixOverShow: true
    })

    setTimeout(() => {
      if(this.stageSixConfirm) return;
      that.setData({
        //canvasShow: false,
        stageSevenShow: true
      })
      setTimeout(() => {
        that.setData({
          stageSixShow: false,
          stageSevenOpac: true
        })
      }, 300);
    }, 12000);
  },
  // 第四个视频点击事件
  stageFiveTap(){
    let that = this;
    this.stageFiveConfirm = true;
    this.setData({
      stageSixShow: true
    })
    setTimeout(() => {
      that.setData({
        stageFiveShow: false,
        stageSixOpac: true
      })
    }, 300);
  },
  // 第四个视频播放完毕
  videoFourEnded(){
    let that = this;
    this.setData({
      stageFiveOverShow: true
    })
    setTimeout(() => {
      if(this.stageFiveConfirm) return;
      that.setData({
        stageSixShow: true
      })
      setTimeout(() => {
        that.setData({
          stageFiveShow: false,
          stageSixOpac: true
        })
      }, 300);
    }, 12000);
  },
  // 第三个视频播放完毕
  videoThreeEnded() {
    //console.log('333');
    let that = this;
    let stageFourPointAni = wx.createAnimation({
      duration: 500,
      timingFunction: 'linear',
    }).translate(-30,-100).opacity(0).step();
    let pointNext = true;
    setInterval(() => {
      if (pointNext){
        stageFourPointAni = wx.createAnimation({
          duration: 0,
        }).translate(0,0).opacity(1).step();
        that.setData({
          stageFourPoint: stageFourPointAni.export()
        })
        pointNext = !pointNext;
      }else{
        stageFourPointAni = wx.createAnimation({
          duration: 500,
          timingFunction: 'linear',
        }).translate(-30,-100).opacity(0).step();
        that.setData({
          stageFourPoint: stageFourPointAni.export()
        })
        pointNext = !pointNext;
      }
    }, 500);

    this.setData({
      canvasShow: true,
      stageFourPoint: stageFourPointAni.export(),
      stageFourOverShow: true
    })

    setTimeout(() => {
      if(this.stageFourConfirm) return;
      that.setData({
        canvasShow: false,
        stageFiveShow: true
      })
      setTimeout(() => {
        that.setData({
          stageFourShow: false,
          stageFiveOpac: true
        })
      }, 300);
    }, 12000);
  },
  // 第二个视频播放完毕
  videoTwoEnded(e) {
    //console.log(e);
    let confirm = true;
    let duration = e.detail.duration;
    let currentTime = e.detail.currentTime;
    let that = this;

    if (duration - currentTime <= 1 && confirm){
      //console.log(222);
      confirm = false;

      that.setData({
        canvasShow: true,
        stageThreeOverShow: true,
        stageThreePointShow: true,
        stageThreeArrow: true,
        stageThreeText: true
      })

      setTimeout(() => {
        if(this.stageThreeConfirm) return;
        that.setData({
          //canvasShow: false,
          stageFourShow: true
        })
        setTimeout(() => {
          that.setData({
            stageThreeShow: false,
            stageFourOpac: true
          })
        }, 300);
      }, 12000);
    }
  },
  // 第一个视频播放完毕
  videoOneEnded() {
    let that = this;
    let animation2 = wx.createAnimation({
      duration: 300,
      timingFunction: 'ease-in',
    }).scale(4).step();
    setTimeout(() => {
      that.setData({
        stageTwoZoomIn: animation2.export(),
      })
      setTimeout(() => {
        that.setData({
          stageTwoShow: false,
          stageThreeShow: true
        })
      }, 300);
      this.bgmPlayFun()
    }, 2000);
  },
  // 点击起航事件
  startTap() {
    console.log('start!!');
    this.bgmPlayFun();
    let that = this;
    let animation = wx.createAnimation({
      duration: 300,
      timingFunction: 'ease-in',
    }).scale(4).step();
    this.setData({
      stageTwoZoomIn: animation.export(),
    })
    setTimeout(() => {
      that.setData({
        stageTwoShow: false,
        stageThreeShow: true
      })
    }, 300);
  },
  bgmPlayFun() {
    let confirm = this.data.bgmComfirm;
    if(confirm) return;
    this.setData({
      musicShow: true,
      bgmComfirm: true
    })
    this.bgm = wx.createInnerAudioContext();
    this.bgm.src = 'https://gqb.oss-cn-shanghai.aliyuncs.com/jlb/bright-shining-love.mp3';
    this.bgm.play();
    this.bgm.onEnded(() => {
      this.bgmPlayFun();
    })
  },
  bgmPauseAndReplay() {
    let confirm = this.data.bgmComfirm;
    if (confirm){
      this.bgm.pause();
      this.setData({
        bgmComfirm: false
      })
    }else{
      this.bgm.play();
      this.setData({
        bgmComfirm: true
      })
    }
  },

  // 画布轨迹绘制与手势方向相关 start
  stageTouchEnd(e) {
    const query = wx.createSelectorQuery()
    query.select('#canvas')
      .fields({ node: true, size: true })
      .exec((res) => {
        const canvas = res[0].node
        const ctx = canvas.getContext('2d')
        const w = res.width;
        const h = res.height;

        const dpr = wx.getSystemInfoSync().pixelRatio
        canvas.width = res[0].width * dpr
        canvas.height = res[0].height * dpr
        ctx.scale(dpr, dpr)
        
        ctx.clearRect(0,0,w,h);
      })

    let direcLeft = false;
    let direcRight = false;
    let direcTop = false;
    let direcBottom = false;
    let that = this;
    if (this.data.touchMoveY - this.data.touchStartY <= -30) {
      direcTop = true;
    }
    if (this.data.touchMoveY - this.data.touchStartY >= 30) {
      direcBottom = true;
    }
    if (this.data.touchMoveX - this.data.touchStartX <= -30) {
      direcLeft = true;
    }
    if (this.data.touchMoveX - this.data.touchStartX >= 30) {
      direcRight = true;
    }

    if (this.data.stageSevenShow) {
      if (direcRight) {
        this.stageSevenConfirm = true;
        console.log('第七场景向右滑动!!!');
        that.setData({
          canvasShow: false,
          stageEightShow: true
        })
        setTimeout(() => {
          that.setData({
            stageSevenShow: false,
            stageEightOpac: true
          })
        }, 300);
      }
      return;
    }
    if (this.data.stageSixShow) {
      if (direcBottom) {
        this.stageSixConfirm = true;
        console.log('第六场景向下滑动!!!');
        that.setData({
          canvasShow: false,
          stageSevenShow: true
        })
        setTimeout(() => {
          that.setData({
            stageSixShow: false,
            stageSevenOpac: true
          })
        }, 300);
      }
      return;
    }
    if (this.data.stageFourShow) {
      if (direcTop && direcLeft) {
        this.stageFourConfirm = true;
        console.log('第四场景向左上滑动!!!');
        that.setData({
          canvasShow: false,
          stageFiveShow: true
        })
        setTimeout(() => {
          that.setData({
            stageFourShow: false,
            stageFiveOpac: true
          })
        }, 300);
      }
      return;
    }
    if (this.data.stageThreeShow) {
      if (direcTop && direcRight) {
        this.stageThreeConfirm = true;
        console.log('第三场景向右上滑动!!!');
        that.setData({
          canvasShow: false,
          stageFourShow: true
        })
        setTimeout(() => {
          that.setData({
            stageThreeShow: false,
            stageFourOpac: true
          })
        }, 300);
      }
    }
  },
  stageTouchStart(e) {
    console.log('touchCanvasStart!!');
    this.setData({
      touchStartXX: e.changedTouches[0].x,
      touchStartYY: e.changedTouches[0].y,
      touchStartX: e.changedTouches[0].x,
      touchStartY: e.changedTouches[0].y
    })
  },
  stageTouchMove(e) {
    let that = this;
    let x = e.changedTouches[0].x;
    let y = e.changedTouches[0].y;
    let start_x = this.data.touchStartXX;
    let start_y = this.data.touchStartYY;

    this.setData({
      touchMoveX: e.changedTouches[0].x,
      touchMoveY: e.changedTouches[0].y
    })

    const query = wx.createSelectorQuery()
    query.select('#canvas')
      .fields({ node: true, size: true })
      .exec((res) => {
        const canvas = res[0].node
        const ctx = canvas.getContext('2d')

        const dpr = wx.getSystemInfoSync().pixelRatio
        canvas.width = res[0].width * dpr
        canvas.height = res[0].height * dpr
        ctx.scale(dpr, dpr)

        ctx.moveTo(start_x, start_y);
        ctx.lineTo(x, y);
        ctx.strokeStyle = 'white';
        ctx.lineWidth = "7";
        ctx.setLineCap = 'round';
        ctx.stroke();
      })
      setTimeout(() => {
        that.setData({
          touchStartXX: e.changedTouches[0].x,
          touchStartYY: e.changedTouches[0].y
        })
      }, 100);
  },
  // 画布轨迹绘制与手势方向相关 end

  onLoad() {
  },
  onReady() {
    this.sound = wx.createInnerAudioContext();
    this.sound.src = 'https://gqb.oss-cn-shanghai.aliyuncs.com/jlb/sound.mp3';
    this.sound.play();

    let that = this;
    let list = this.data.numberList;
    let numArr = [];
    let numConfirm = false;
    wx.request({
      url: 'https://jlb.08k.co/num_api',
      header: {
        'content-type': 'application/json' // 默认值
      },
      success: (res) =>  {
        numArr = res.data.data.toString().split('');
        console.log(numArr);
        list[0].nowNum = 'to' + numArr[0];
        list[1].nowNum = 'to' + numArr[1];
        list[2].nowNum = 'to' + numArr[2];
        list[3].nowNum = 'to' + numArr[3];
        that.setData({
          numberList: list
        })
        numConfirm = true
      },
      fail: (err) => {
        console.log('error!!');
      }
    })
    setTimeout(() => {
      if (!numConfirm) {
        let num = Math.floor(Math.random()*1000) + 1000;
        console.log();
        numArr = num.toString().split('');
        console.log(numArr);
        list[0].nowNum = 'to' + numArr[0];
        list[1].nowNum = 'to' + numArr[1];
        list[2].nowNum = 'to' + numArr[2];
        list[3].nowNum = 'to' + numArr[3];
        that.setData({
          numberList: list
        })
      }
    }, 800);
    setTimeout(() => {
      that.setData({
        stageTwoShow: true
      })
      setTimeout(() => {
        that.setData({
          stageOneShow: false,
          stageTwoOpac: true
        })
      }, 800);
    }, 2500);
  },
})
